package com.fadadianqi.mall.product.dao.ibatis;

import com.fadadianqi.commons.GenericDAOSuport;
import com.fadadianqi.mall.product.dao.NavItemSPUDAO;
import com.fadadianqi.mall.product.model.NavItemSPU;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by aroot on 2/11/14.
 */
@Component
public class NavItemSPUDAOImpl extends GenericDAOSuport<String, NavItemSPU> implements NavItemSPUDAO
{
    @Override
    protected Class<?> getObjectClass() {
        return NavItemSPU.class;
    }

    @Override
    protected String getTableName() {
        return "mall_nav_item_spu";
    }

    @Override
    public NavItemSPU getByNavIdAndSPUId(String navId, String spuId) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("navId", navId);
        map.put("spuId", spuId);
        return super.getByPropertys(map);
    }

    @Override
    public List<NavItemSPU> findBySpuId(String spuId) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("spuId", spuId);
        return super.findByPropertys(map);
    }

    @Override
    public void removeBySpuId(String spuId) {
        super.removeByProperty("spuId", spuId);
    }
}
